#include "atomic.h"

#include <atomic>
#include <iostream>
#include <thread>

extern atomic<bool> x;
extern atomic<bool> y;
extern atomic<int> z;

int main(int argc, char** argv) {
	x = false;
	y = false;
	z = 0;
	thread a(write_x);
	thread b(write_y);
	thread c(read_x_then_y);
	thread d(read_y_then_x);
	a.join();
	b.join();
	c.join();
	d.join();

	cout <<"z = " << z.load() << endl;
	return 0;
}

